contentTransition
The contentTransition modifier specifies a transition animation to apply when the content within a single view changes. Unlike view-level transitions (such as .transition(.move)), contentTransition animates changes in content rather than the insertion or removal of the view itself.
This is particularly useful when updating the contents of views like Text, Image, or symbol-based Image(systemName: ...), providing smooth visual feedback on state or data changes.
Type
Supported ContentTransition Values
"identity"
- No animation is applied to the content change.
- The view updates instantly with no visual transition.
"interpolate"
- The view attempts to interpolate between the old and new content where appropriate.
- Best used with animatable types such as
Color,Shape, orViewinterpolations.
"opacity"
- Applies a fade effect: old content fades out while new content fades in.
- Works well with general-purpose views.
"numericText"
- Specialized transition for
Textviews displaying numbers. - Animates character changes in a way that emphasizes numerical progression.
"numericTextCountsUp"
- Similar to
"numericText", but optimized for numeric increments. - Intended for counter-like transitions.
"numericTextCountsDown"
- Optimized for numeric decrements.
- Useful for countdowns or decreasing counters.
"symbolEffect"
- Applies a default symbol animation when a symbol image changes.
- Only affects symbol-based images (
Image(systemName: ...)) and has no effect on other views.
"symbolEffectAutomatic"
- Uses platform-adaptive symbol animation depending on context.
- Typically provides fade, scale, or morphing effects between symbols.
"symbolEffectReplace"
- Replaces the layers of one symbol image with another.
- Provides a more visually fluid symbol swap than abrupt replacement.
"symbolEffectAppear" / "symbolEffectDisappear"
- Explicit transitions for symbol insertion and removal, respectively.
- These may be combined with visibility-based state changes.
"symbolEffectScale"
- Scales the symbol up or down during the content change.
- Works well for symbol emphasis or status feedback.
Summary
This modifier is ideal for providing subtle, performant feedback in data-driven UI updates while maintaining view identity and layout stability. It is particularly effective in dashboards, counters, toggles, icon transitions, and numerically dynamic interfaces.
